type replacedAll = ReplaceAll<'t y p e s', ' ', ''> // 期望是 'types'

type ReplaceAll<
  S extends string,
  T extends string,
  R extends string> = S extends `${infer O}${T}${infer Rest}`
  ? ReplaceAll<`${O}${R}${Rest}`, T, R>
  : S